package com.ruoyi.web.controller.recommend.student;


import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.domain.model.LoginUser;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.enums.OperatorType;
import com.ruoyi.student.domain.StudentBaseInfo;
import com.ruoyi.student.domain.StudentRecommendInfo;
import com.ruoyi.student.domain.vo.*;
import com.ruoyi.student.service.IStudentBaseInfoService;
import com.ruoyi.student.service.IStudentRecommendInfoService;
import com.ruoyi.student.service.IStudentService;
import com.ruoyi.system.service.ISysConfigService;
import com.ruoyi.system.service.ISysPlaceService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;

@RestController("StudentRecommendController")
@RequestMapping("/student/recommend")
public class StudentRecommendController extends BaseController {


    @Resource
    private IStudentRecommendInfoService studentRecommendInfoService;


    @Resource
    private IStudentBaseInfoService studentBaseInfoService;


    @Resource
    private IStudentService studentService;


    /**
     * 查询登入学生的生源所在地
     *
     * @return
     */
    @GetMapping("/source")
    public AjaxResult selectStudentSource() {
        LoginUser loginUser = getLoginUser();
        StudentBaseInfo studentBaseInfo = studentBaseInfoService.selectStudentBaseInfoByCode(loginUser.getUsername());
        SelectStudentSourceVo vo = new SelectStudentSourceVo();
        vo.setCode(studentBaseInfo.getCode());
        vo.setSourceName(studentBaseInfo.getSource());
        vo.setSourceFullName(studentBaseInfo.getSourceFullName());
        return success(vo);
    }


    /**
     * 获取学生的基础采集信息
     *
     * @return
     */
    @Log(title = "学生-获取自己的基础信息", operatorType = OperatorType.MANAGE, businessType = BusinessType.QUERY)
    @GetMapping("/base")
    public AjaxResult selectStudentBaseInfo() {
        LoginUser loginUser = getLoginUser();
        StudentBaseInfo studentBaseInfo = studentBaseInfoService.selectStudentBaseInfoByCode(loginUser.getUsername());
        StudentRecommendInfo studentRecommendInfo = studentRecommendInfoService.selectStudentRecommendInfoByCode(loginUser.getUsername());
        SelectStudentBaseInfoVo vo = new SelectStudentBaseInfoVo();
        vo.setId(studentBaseInfo.getId());
        vo.setName(studentBaseInfo.getName());
        vo.setCode(studentBaseInfo.getCode());
        vo.setPhoneNumber(studentBaseInfo.getPhoneNumber());
        vo.setEmail(studentRecommendInfo.getEmail());
        vo.setQq(studentRecommendInfo.getQq());
        vo.setHomeAddress(studentRecommendInfo.getHomeAddress());
        vo.setHomeCode(studentRecommendInfo.getHomeCode());
        vo.setHomePhone(studentRecommendInfo.getHomePhone());
        vo.setIsHkInSchool(studentRecommendInfo.getIsHkInSchool());
        vo.setIsCityStudent(studentRecommendInfo.getIsCityStudent());
        vo.setRxqhkszdpcs(studentRecommendInfo.getRxqhkszdpcs());
        vo.setRxqdaszdw(studentRecommendInfo.getRxqdaszdw());
        return success(vo);
    }


    /**
     * 获取学生的推荐表采集信息
     *
     * @return
     */
    @Log(title = "学生-获取自己的推荐表信息", operatorType = OperatorType.MANAGE, businessType = BusinessType.QUERY)
    @GetMapping("/recommend")
    public AjaxResult selectStudentRecommendInfo() {
        LoginUser loginUser = getLoginUser();
        StudentBaseInfo studentBaseInfo = studentBaseInfoService.selectStudentBaseInfoByCode(loginUser.getUsername());
        StudentRecommendInfo studentRecommendInfo = studentRecommendInfoService.selectStudentRecommendInfoByCode(loginUser.getUsername());
        SelectStudentRecommendInfoVo selectStudentRecommendInfoVo = new SelectStudentRecommendInfoVo();
        selectStudentRecommendInfoVo.setName(studentBaseInfo.getName());
        selectStudentRecommendInfoVo.setCode(studentBaseInfo.getCode());
        selectStudentRecommendInfoVo.setPoliticalStatus(studentBaseInfo.getPoliticalStatus());
        selectStudentRecommendInfoVo.setForeignLanguageEvel(studentRecommendInfo.getForeignLanguageEvel());
        selectStudentRecommendInfoVo.setComputerLevel(studentRecommendInfo.getComputerLevel());
        selectStudentRecommendInfoVo.setJobIntention(studentRecommendInfo.getJobIntention());
        selectStudentRecommendInfoVo.setRewardPunishmentPrize1(studentRecommendInfo.getRewardPunishmentPrize1());
        selectStudentRecommendInfoVo.setRewardPunishmentPrize2(studentRecommendInfo.getRewardPunishmentPrize2());
        selectStudentRecommendInfoVo.setRewardPunishmentPrize3(studentRecommendInfo.getRewardPunishmentPrize3());
        selectStudentRecommendInfoVo.setRewardPunishmentPrize4(studentRecommendInfo.getRewardPunishmentPrize4());
        selectStudentRecommendInfoVo.setRewardPunishmentPrize5(studentRecommendInfo.getRewardPunishmentPrize5());
        selectStudentRecommendInfoVo.setWorkContent1(studentRecommendInfo.getWorkContent1());
        selectStudentRecommendInfoVo.setWorkContent2(studentRecommendInfo.getWorkContent2());
        selectStudentRecommendInfoVo.setWorkContent3(studentRecommendInfo.getWorkContent3());
        selectStudentRecommendInfoVo.setWorkContent4(studentRecommendInfo.getWorkContent4());
        selectStudentRecommendInfoVo.setWorkContent5(studentRecommendInfo.getWorkContent5());
        selectStudentRecommendInfoVo.setQualification(studentRecommendInfo.getQualification());
        selectStudentRecommendInfoVo.setStudentRecommendSubmit(studentRecommendInfo.getStudentRecommendSubmit());
        selectStudentRecommendInfoVo.setCounselorRecommendCheck(studentRecommendInfo.getCounselorRecommendCheck());
        selectStudentRecommendInfoVo.setDepartmentOpinion(studentRecommendInfo.getDepartmentOpinion());
        return success(selectStudentRecommendInfoVo);
    }


    /**
     * 更新学生推荐表基础信息
     *
     * @param vo
     * @return
     */
    @Log(title = "学生-更新自己的基础信息", operatorType = OperatorType.MANAGE, businessType = BusinessType.UPDATE)
    @PutMapping("/base")
    public AjaxResult editStudentBaseInfo(@Valid @RequestBody EditStudentBaseInfoVo vo) {
        LoginUser loginUser = getLoginUser();
        vo.setCode(loginUser.getUsername());
        return success(studentService.editStudentRecommendBaseInfo(vo));
    }


    /**
     * 修改学生生源所在地
     *
     * @param place
     * @return
     */
    @Log(title = "学生-修改自己的生源所在地", operatorType = OperatorType.MANAGE, businessType = BusinessType.UPDATE)
    @PutMapping("/source/{place}")
    public AjaxResult editStudentSource(@PathVariable("place") String place) {
        LoginUser loginUser = getLoginUser();
        return success(studentBaseInfoService.editStudentSource(loginUser.getUsername(), place));
    }


    /**
     * 修改学生推荐表推荐信息
     *
     * @param vo
     * @return
     */
    @Log(title = "学生-更新自己的推荐表信息", operatorType = OperatorType.MANAGE, businessType = BusinessType.UPDATE)
    @PutMapping("/recommend")
    public AjaxResult editStudentRecommendInfo(@RequestBody EditStudentRecommendInfoVo vo) {
        LoginUser loginUser = getLoginUser();
        vo.setCode(loginUser.getUsername());
        return success(studentService.editStudentRecommendRecommendInfo(vo));
    }

    /**
     * 获取学生确认信息
     *
     * @return
     */
    //@Log(title = "学生-更新自己的基础信息", operatorType = OperatorType.MANAGE, businessType = BusinessType.UPDATE)
    @GetMapping("/checkInfo")
    public AjaxResult selectStudentCheckInfo() {
        LoginUser loginUser = getLoginUser();
        return success(studentService.selectStudentRecommendCheckInfo(loginUser.getUsername()));
    }


    /**
     * 学生确认推荐表信息
     *
     * @return
     */
    @Log(title = "学生-确认自己的推荐表信息", operatorType = OperatorType.MANAGE, businessType = BusinessType.UPDATE)
    @PutMapping("/confirmInfo")
    public AjaxResult confirmInfo() {
        LoginUser loginUser = getLoginUser();
        return success(studentService.confirmInfo(loginUser.getUsername()));
    }
}
